<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('媒体资料管理')"/>
    <script type="text/javascript" th:src="@{/pdata/pdata.js}"></script>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">


    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="mediaSearch">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>业务类型：</label>
                            <select name="mediaType"
                                    th:with="type=${@dict.getType('work_paper_type')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>分类：</label>
                            <select class="form-control" name="category"
                                    th:with="type=${@dict.getType('work_category')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>行业：</label>
                            <select class="form-control" name="industry"
                                    th:with="type=${@dict.getType('work_industry')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>媒体名称：</label>
                            <input type="text" name="mediaName"/>
                        </li>
                        <li>
                            <label>平台：</label>
                            <select class="form-control" name="platform"
                                    th:with="type=${@dict.getType('work_platform')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>收录：</label>
                            <select name="included"
                                    th:with="type=${@dict.getType('work_included')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>链接：</label>
                            <select name="link"
                                    th:with="type=${@dict.getType('work_publish_link')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>周末发稿：</label>
                            <select name="weekendPress"
                                    th:with="type=${@dict.getType('work_publish_paper')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>出稿日期：</label>
                            <select name="publish"
                                    th:with="type=${@dict.getType('work_publish_date')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>价格范围：</label>
                            <input type="text" name="beginPrice"/>
                            <span>-</span>
                            <input type="text" name="endPrice"/>
                        </li>

                        <li>
                            <label>地区：</label>
                            <select name="province" id="province" class="form-control">
                            </select>
                        </li>
                        <li>
                            <select name="city" id="city" class="form-control">
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="commonSearch();"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$('#mediaSearch')[0].reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="work:media:export">
                                <i class="fa fa-download"></i> 导出
                            </a>
                         </li>
                    </ul>
                </div>
            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="media-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: bootstrap-suggest-js"/>
<th:block th:include="include :: bootstrap-typeahead-js"/>
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-select-js" />
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "work/media"
    var categoryDatas = [[${@dict.getType('work_category')}]];
    var authDatas = [[${@dict.getType('work_auth')}]];
    var industryDatas = [[${@dict.getType('work_industry')}]];
    var includedDatas = [[${@dict.getType('work_included')}]];
    var linkDatas = [[${@dict.getType('work_publish_link')}]];
    var weekendPressDatas = [[${@dict.getType('work_publish_paper')}]];
    var publishDatas = [[${@dict.getType('work_publish_date')}]];
    var plusVDatas = [[${@dict.getType('work_plus_v')}]];
    var isMasterDatas = [[${@dict.getType('sys_yes_no')}]];
    var platformDatas = [[${@dict.getType('work_platform')}]];
    var isDirectDatas = [[${@dict.getType('sys_yes_no')}]];
    var vOriginalDatas = [[${@dict.getType('work_original_v')}]];
    var priceDatas = [[${@dict.getType('work_price_type')}]];
    var paperDatas = [[${@dict.getType('work_paper_type')}]];


    $(function () {
        var html = "<option value=''>== 请选择 ==</option>";
        $("#city").append(html);

        $.each(pdata, function (idx, item) {
            if (parseInt(item.level) == 0) {
                html += "<option value='" + item.names + "' exid='" + item.code + "'>" + item.names + "</option>";
            }
        });
        $("#province").append(html);

        $("#province").change(function () {
            if ($(this).val() == "") return;
            $("#city option").remove();

            var code = $(this).find("option:selected").attr("exid");
            code = code.substring(0, 2);
            var html = "<option value=''>== 请选择 ==</option>";

            $.each(pdata, function (idx, item) {
                if (parseInt(item.level) == 1 && code == item.code.substring(0, 2)) {
                    html += "<option value='" + item.names + "' exid='" + item.code + "'>" + item.names + "</option>";
                }
            });
            $("#city").append(html);
        });




    });



    function queryParams(params) {
        var search = $.table.queryParams(params);
        search.category = $("#mediaSearch [name='category']").val();
        search.industry = $("#mediaSearch [name='industry']").val();
        search.mediaName = $("#mediaSearch [name='mediaName']").val();
        search.platform = $("#mediaSearch [name='platform']").val();
        search.province = $("#mediaSearch [name='province']").val();
        search.city = $("#mediaSearch [name='city']").val();
        search.params = {};
        search.params["beginPrice"] = $("#mediaSearch [name='beginPrice']").val();
        search.params["endPrice"] = $("#mediaSearch [name='endPrice']").val();
        return search;


    }


    function commonSearch() {
        var mt = $("#mediaSearch [name='mediaType']").val();
        var pre = ctx;
        var options = {};

        switch (mt) {
            case "1":
                pre = pre + "work/net";
                options = {
                    id: "media-table",
                    url: pre + "/list",
                    queryParams: queryParams,
                    showSearch: false,
                    showRefresh: false,
                    showToggle: false,
                    showColumns: false,
                    exportUrl: pre+"/export",
                    modalName:"网络媒体资料",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'mediaId',
                            title: '媒体ID'
                        },
                        {
                            field: 'mediaName',
                            title: '媒体名称'
                        },
                        {
                            field: 'province',
                            title: '省份'
                        },
                        {
                            field: 'city',
                            title: '地市'
                        },
                        {
                            field: 'category',
                            title: '分类',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(categoryDatas, value);
                            }
                        },
                        {
                            field: 'industry',
                            title: '行业',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(industryDatas, value);
                            }
                        },
                        {
                            field: 'included',
                            title: '收录',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(includedDatas, value);
                            }
                        },
                        {
                            field: 'price',
                            title: '价格'
                        },
                        {
                            field: 'link',
                            title: '发布链接',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(linkDatas, value);
                            }
                        },
                        {
                            field: 'weekendPress',
                            title: '周末发稿',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(weekendPressDatas, value);
                            }
                        },
                        {
                            field: 'mediaCase',
                            title: '案例'
                        },
                        {
                            field: 'publish',
                            title: '出稿日期',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(publishDatas, value);
                            }
                        },
                        {
                            field: 'createBy',
                            title: '登记人'
                        },
                        {
                            field: 'remark',
                            title: '备注'
                        }]
                };
                $.table.destroy('media-table');
                $.table.init(options);

                break;
            case "2":
                pre = pre + "work/wb";
                options = {
                    url: pre + "/list",
                    id: "media-table",
                    queryParams: queryParams,
                    showSearch: false,
                    showRefresh: false,
                    showToggle: false,
                    showColumns: false,
                    exportUrl: pre+"/export",
                    modalName:"微博媒体资料",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'mediaId',
                            title: '媒体ID'
                        },
                        {
                            field: 'mediaName',
                            title: '微博名称'
                        },
                        {
                            field: 'province',
                            title: '省份'
                        },
                        {
                            field: 'city',
                            title: '地市'
                        },
                        {
                            field: 'industry',
                            title: '行业',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(industryDatas, value);
                            }
                        },
                        {
                            field: 'plusV',
                            title: '加V',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(plusVDatas, value);
                            }
                        },
                        {
                            field: 'fans',
                            title: '粉丝数(万)'
                        },
                        {
                            field: 'link',
                            title: '链接'
                        },
                        {
                            field: 'wDirectPrice',
                            title: '微任务直发价'
                        },
                        {
                            field: 'wForwardPrice',
                            title: '微任务转发价'
                        },
                        {
                            field: 'directPrice',
                            title: '直发价'
                        },
                        {
                            field: 'forwardPrice',
                            title: '转发价'
                        },
                        {
                            field: 'createBy',
                            title: '登记人'
                        },
                        {
                            field: 'remark',
                            title: '备注'
                        }]
                };
                $.table.destroy('media-table');
                $.table.init(options);

                break;
            case "3":
                pre = pre + "work/wx";
                options = {
                    url: pre + "/list",
                    id: "media-table",
                    queryParams: queryParams,
                    showSearch: false,
                    showRefresh: false,
                    showToggle: false,
                    showColumns: false,
                    exportUrl: pre+"/export",
                    modalName:"微信媒体资料",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'mediaId',
                            title: '媒体ID'
                        },
                        {
                            field: 'mediaName',
                            title: '微信名称'
                        },
                        {
                            field: 'wxNo',
                            title: '微信号'
                        },
                        {
                            field: 'province',
                            title: '省份'
                        },
                        {
                            field: 'city',
                            title: '地市'
                        },
                        {
                            field: 'category',
                            title: '分类',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(categoryDatas, value);
                            }
                        },
                        {
                            field: 'fans',
                            title: '粉丝数(万)'
                        },
                        {
                            field: 'auth',
                            title: '认证',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(authDatas, value);
                            }
                        },
                        {
                            field: 'readCount',
                            title: '阅读量'
                        },
                        {
                            field: 'leadPrice',
                            title: '头条'
                        },
                        {
                            field: 'secondPrice',
                            title: '次条'
                        },

                        {
                            field: 'remark',
                            title: '备注'
                        },
                        {
                            field: 'createBy',
                            title: '登记人'
                        }]
                };
                $.table.destroy('media-table');
                $.table.init(options);

                break;
            case "4":
                pre = pre + "work/plane";
                options = {
                    url: pre + "/list",
                    id: "media-table",
                    queryParams: queryParams,
                    showSearch: false,
                    showRefresh: false,
                    showToggle: false,
                    showColumns: false,
                    exportUrl: pre+"/export",
                    modalName:"平面媒体资料",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'mediaId',
                            title: '媒体ID'
                        },
                        {
                            field: 'mediaName',
                            title: '媒体名称'
                        },
                        {
                            field: 'province',
                            title: '省份'
                        },
                        {
                            field: 'city',
                            title: '地市'
                        },
                        {
                            field: 'industry',
                            title: '行业',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(industryDatas, value);
                            }
                        },
                        {
                            field: 'isMaster',
                            title: '是否主报',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(isMasterDatas, value);
                            }
                        },
                        {
                            field: 'price',
                            title: '单价'
                        },

                        {
                            field: 'remark',
                            title: '备注'
                        },
                        {
                            field: 'createBy',
                            title: '登记人'
                        }]
                };
                $.table.destroy('media-table');
                $.table.init(options);

                break;
            case "5":
                pre = pre + "work/app";
                options = {
                    url: pre + "/list",
                    id: "media-table",
                    queryParams: queryParams,
                    showSearch: false,
                    showRefresh: false,
                    showToggle: false,
                    showColumns: false,
                    exportUrl: pre+"/export",
                    modalName:"APP客户端媒体资料",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'mediaId',
                            title: '媒体ID'
                        },
                        {
                            field: 'mediaName',
                            title: '媒体名称'
                        },
                        {
                            field: 'platform',
                            title: '平台',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(platformDatas, value);
                            }
                        },

                        {
                            field: 'industry',
                            title: '行业',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(industryDatas, value);
                            }
                        },
                        {
                            field: 'price',
                            title: '价格'
                        },
                        {
                            field: 'mediaCase',
                            title: '案例'
                        },
                        {
                            field: 'publish',
                            title: '出稿日期',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(publishDatas, value);
                            }
                        },
                        {
                            field: 'link',
                            title: '链接'
                        },
                        {
                            field: 'vOriginal',
                            title: '加V原创',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(vOriginalDatas, value);
                            }
                        },
                        {
                            field: 'fans',
                            title: '粉丝数'
                        },
                        {
                            field: 'weekendPress',
                            title: '周末发稿',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(weekendPressDatas, value);
                            }
                        },

                        {
                            field: 'createBy',
                            title: '登记人'
                        },
                        {
                            field: 'remark',
                            title: '备注'
                        }]
                };
                $.table.destroy('media-table');
                $.table.init(options);

                break;
            case "6":
                pre = pre + "work/flow";
                options = {
                    url: pre + "/list",
                    id: "media-table",
                    queryParams: queryParams,
                    showSearch: false,
                    showRefresh: false,
                    showToggle: false,
                    showColumns: false,
                    exportUrl: pre+"/export",
                    modalName:"刷量媒体资料",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'mediaId',
                            title: '媒体ID'
                        },
                        {
                            field: 'platform',
                            title: '平台',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(platformDatas, value);
                            }
                        },
                        {
                            field: 'category',
                            title: '分类',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(categoryDatas, value);
                            }
                        },
                        {
                            field: 'isDirect',
                            title: '是否直营',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(isDirectDatas, value);
                            }
                        },
                        {
                            field: 'createBy',
                            title: '登记人'
                        },
                        {
                            field: 'remark',
                            title: '备注'
                        }]
                };
                $.table.destroy('media-table');
                $.table.init(options);

                break;
            default:
                alert('error')
        }
    }


</script>
</body>
</html>
